version 12.0
set more off

// main analysis
* model 1a
zinb rosvFATBEST ///
constOVERLAP constFRAC, ///
inflate (constOVERLAP constFRAC) robust cluster(dyadID)
* model 1b
zinb rosvFATBEST ///
constOVERLAP constPOL, ///
inflate (constOVERLAP constPOL) robust cluster(dyadID)
* model 2a
zinb rosvFATBEST ///
popdense_ln constOVERLAP constFRAC, ///
inflate (popdense_ln constOVERLAP constFRAC) robust cluster(dyadID)
* model 2b
zinb rosvFATBEST ///
popdense_ln constOVERLAP constPOL, ///
inflate (popdense_ln constOVERLAP constPOL) robust cluster(dyadID)
* model 3a
zinb rosvFATBEST ///
popdense_ln resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (popdense_ln resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 3b
zinb rosvFATBEST ///
popdense_ln resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (popdense_ln resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)
* model 4a
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)


// alternative specification: DV (ln)
* model 1a
zinb rosvFATBEST_ln ///
constOVERLAP constFRAC, ///
inflate (constOVERLAP constFRAC) robust cluster(dyadID)
* model 1b
zinb rosvFATBEST_ln ///
constOVERLAP constPOL, ///
inflate (constOVERLAP constPOL) robust cluster(dyadID)
* model 2a
zinb rosvFATBEST_ln ///
popdense_ln constOVERLAP constFRAC, ///
inflate (popdense_ln constOVERLAP constFRAC) robust cluster(dyadID)
* model 2b
zinb rosvFATBEST_ln ///
popdense_ln constOVERLAP constPOL, ///
inflate (popdense_ln constOVERLAP constPOL) robust cluster(dyadID)
* model 3a
zinb rosvFATBEST_ln ///
popdense_ln resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (popdense_ln resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID) iter(100)
* model 3b
zinb rosvFATBEST_ln ///
popdense_ln resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (popdense_ln resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)
* model 4a
zinb rosvFATBEST_ln ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST_ln ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)


// alternative specification: DV t-1
* model 1a
zinb rosvFATBEST ///
rosvFATBEST_t1 constOVERLAP constFRAC, ///
inflate (rosvFATBEST_t1 constOVERLAP constFRAC) robust cluster(dyadID)
* model 1b
zinb rosvFATBEST ///
rosvFATBEST_t1 constOVERLAP constPOL, ///
inflate (rosvFATBEST_t1 constOVERLAP constPOL) robust cluster(dyadID)
* model 2a
zinb rosvFATBEST ///
rosvFATBEST_t1 popdense_ln constOVERLAP constFRAC, ///
inflate (rosvFATBEST_t1 popdense_ln constOVERLAP constFRAC) robust cluster(dyadID)
* model 2b
zinb rosvFATBEST ///
rosvFATBEST_t1 popdense_ln constOVERLAP constPOL, ///
inflate (rosvFATBEST_t1 popdense_ln constOVERLAP constPOL) robust cluster(dyadID)
* model 3a
zinb rosvFATBEST ///
rosvFATBEST_t1 popdense_ln resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (rosvFATBEST_t1 popdense_ln resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 3b
zinb rosvFATBEST ///
rosvFATBEST_t1 popdense_ln resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (rosvFATBEST_t1 popdense_ln resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)
* model 4a
zinb rosvFATBEST ///
rosvFATBEST_t1 popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (rosvFATBEST_t1 popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST ///
rosvFATBEST_t1 popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (rosvFATBEST_t1 popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)


// alternative specification: battle deaths t-1 and gov't OSV t-1
* model 4a
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_t1ln gosvFATBEST_t1ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (popdense_ln rebstrong bdBest_t1ln gosvFATBEST_t1ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_t1ln gosvFATBEST_t1ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (popdense_ln rebstrong bdBest_t1ln gosvFATBEST_t1ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)


// alternative specification: NSA rebel organization variables
* model 4a
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared strengthcent mobcap constOVERLAP constFRAC, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared strengthcent mobcap constOVERLAP constFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared strengthcent mobcap constOVERLAP constPOL, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared strengthcent mobcap constOVERLAP constPOL) robust cluster(dyadID)


// alternative specification: territorial control
* model 4a
zinb rosvFATBEST ///
popdense_ln rebstrong effterrcont2 bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC, ///
inflate (popdense_ln rebstrong effterrcont2 bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST ///
popdense_ln rebstrong effterrcont2 bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL, ///
inflate (popdense_ln rebstrong effterrcont2 bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP constPOL) robust cluster(dyadID)


// alternative specification: EPR constituency variables
* model 1a
zinb rosvFATBEST ///
eprstatusPOW eprFRAC, ///
inflate (eprstatusPOW eprFRAC) robust cluster(dyadID)
* model 1b
zinb rosvFATBEST ///
eprstatusPOW eprPOL, ///
inflate (eprstatusPOW eprPOL) robust cluster(dyadID)
* model 2a
zinb rosvFATBEST ///
popdense_ln eprstatusPOW eprFRAC, ///
inflate (popdense_ln eprstatusPOW eprFRAC) robust cluster(dyadID)
* model 2b
zinb rosvFATBEST ///
popdense_ln eprstatusPOW eprPOL, ///
inflate (popdense_ln eprstatusPOW eprPOL) robust cluster(dyadID)
* model 3a
zinb rosvFATBEST ///
popdense_ln resfinance1 ideologyETHNO eprstatusPOW eprFRAC, ///
inflate (popdense_ln resfinance1 ideologyETHNO eprstatusPOW eprFRAC) robust cluster(dyadID)
* model 3b
zinb rosvFATBEST ///
popdense_ln resfinance1 ideologyETHNO eprstatusPOW eprPOL, ///
inflate (popdense_ln resfinance1 ideologyETHNO eprstatusPOW eprPOL) robust cluster(dyadID)
* model 4a
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO eprstatusPOW eprFRAC, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO eprstatusPOW eprFRAC) robust cluster(dyadID)
* model 4b
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO eprstatusPOW eprPOL, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO eprstatusPOW eprPOL) robust cluster(dyadID)


// interactions (using models 4a and 4b)
* ideologyETHNO#constOVERLAP
quietly ///
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 constFRAC i.ideologyETHNO##c.constOVERLAP, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 constFRAC i.ideologyETHNO##c.constOVERLAP) robust cluster(dyadID)
margins, dydx(ideologyETHNO) at(constOVERLAP==(0(0.1)1) popdense_ln==3.45 rebstrong==0 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 resfinance1==0 constFRAC==0.23)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-5 5)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
* ideologyETHNO#constFRAC
quietly ///
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 constOVERLAP i.ideologyETHNO##c.constFRAC, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 constOVERLAP i.ideologyETHNO##c.constFRAC) robust cluster(dyadID)
margins, dydx(ideologyETHNO) at(constFRAC==(0(0.1)1) popdense_ln==3.45 rebstrong==0 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 resfinance1==0 constOVERLAP==0.32)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-5 5)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
* ideologyETHNO#constPOL		 
quietly ///
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 constOVERLAP i.ideologyETHNO##c.constPOL, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 constOVERLAP i.ideologyETHNO##c.constPOL) robust cluster(dyadID)
margins, dydx(ideologyETHNO) at(constPOL==(0(0.1)1) popdense_ln==3.45 rebstrong==0 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 resfinance1==0 constOVERLAP==0.32)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-5 5)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)     
* resfinance1#constOVERLAP
quietly ///
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared ideologyETHNO constFRAC i.resfinance1##c.constOVERLAP, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared ideologyETHNO constFRAC i.resfinance1##c.constOVERLAP) robust cluster(dyadID)
margins, dydx(resfinance1) at(constOVERLAP==(0(0.1)1) popdense_ln==3.45 rebstrong==0 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 ideologyETHNO==0 constFRAC==0.23)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-200 200)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
* resfinance1#constFRAC
quietly ///
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared ideologyETHNO constOVERLAP i.resfinance1##c.constFRAC, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared ideologyETHNO constOVERLAP i.resfinance1##c.constFRAC) robust cluster(dyadID)
margins, dydx(resfinance1) at(constFRAC==(0(0.1)1) popdense_ln==3.45 rebstrong==0 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 ideologyETHNO==0 constOVERLAP==0.32)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-200 200)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)  
* resfinance1#constPOL
quietly ///
zinb rosvFATBEST ///
popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared ideologyETHNO constOVERLAP i.resfinance1##c.constPOL, ///
inflate (popdense_ln rebstrong bdBest_ln gosvFATBEST_ln duration25 duration25_squared ideologyETHNO constOVERLAP i.resfinance1##c.constPOL) robust cluster(dyadID)
margins, dydx(resfinance1) at(constPOL==(0(0.1)1) popdense_ln==3.45 rebstrong==0 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 ideologyETHNO==0 constOVERLAP==0.32)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-200 200)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
* rebstrong#constOVERLAP
quietly ///
zinb rosvFATBEST ///
popdense_ln bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constFRAC i.rebstrong##c.constOVERLAP, ///
inflate (popdense_ln bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constFRAC i.rebstrong##c.constOVERLAP) robust cluster(dyadID)
margins, dydx(rebstrong) at(constOVERLAP==(0(0.1)1) popdense_ln==3.45 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 resfinance1==0 ideologyETHNO==0 constFRAC==0.23)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-5 5)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
* rebstrong#constFRAC
quietly ///
zinb rosvFATBEST ///
popdense_ln bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP i.rebstrong##c.constFRAC, ///
inflate (popdense_ln bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP i.rebstrong##c.constFRAC) robust cluster(dyadID)
margins, dydx(rebstrong) at(constFRAC==(0(0.1)1) popdense_ln==3.45 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 resfinance1==0 ideologyETHNO==0 constOVERLAP==0.32)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-5 5)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
* rebstrong#constPOL
quietly ///
zinb rosvFATBEST ///
popdense_ln bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP i.rebstrong##c.constPOL, ///
inflate (popdense_ln bdBest_ln gosvFATBEST_ln duration25 duration25_squared resfinance1 ideologyETHNO constOVERLAP i.rebstrong##c.constPOL) robust cluster(dyadID)
margins, dydx(rebstrong) at(constPOL==(0(0.1)1) popdense_ln==3.45 bdBest_ln==5.24 gosvFATBEST_ln==-7.736488 duration25==5.7 duration25_squared==85.03 resfinance1==0 ideologyETHNO==0 constOVERLAP==0.32)
marginsplot, recast(line) recastci(rarea) ///
			 legend(ring(0) position(2) size(small)) ///
			 yscale(range(-5 5)) ylabel(#5) yline(0) xlabel(.2(.2)1) ///
             scheme(lean1)
